<template>
  <div class="error-page">
    <template v-if="error.statusCode === 404">
      <img class="error-logo" src="~/assets/img/ic_404.png">
      <div class="title">抱歉您要找的页面不存在</div>
    </template>
    <template v-else>
      <img class="error-logo" src="~/assets/img/ic_500.png">
      <div class="title">抱歉您打开的页面出错了</div>
    </template>
    <a class="btn btn-primary" @click="back">返回上一页</a>
  </div>
</template>

<script>
  export default {
    props: ['error'],
    mounted() {
      console.log(this.error);
      // if(this.error && this.error.message.startsWith('Loading chunk')){
      //   if(!location.search.match('time=')){
      //     this.$alert('页面已更新').then(()=>{
      //         location.href = location.href + (location.search ? '&' : '?') + 'time=' + (+new Date);
      //     })
      //   }
      // }
    },
    methods:{
      back(){
        if(!window.PAGE_FROM.name){//如果没有上一页的情况下，回到首页
          this.$router.replace({name:'index'})
        }else{
          this.$router.back();
        }
      }
    }
  }

</script>
<style lang="less" scoped>
  .error-page {
    padding: 260px 100px 100px;
    background: #fff;
    text-align: center;
    display: flex;
    align-items: center;
    flex-direction: column;
    font-family: sans-serif;
    -ms-text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;

    .error-logo {
      display: block;
      width: 239px;
      height: 325px;;
    }
    .title {
      margin-top:30px;
      font-size:28px;
      color:#999;
      text-align: center;
    }
    .btn {
      width:360px;
      margin-top:50px;
    }
  }
</style>
